package com.webserver.core;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

/**
 * 该线程负责与指定客户端完成HTTP协议的交互过程
 *
 */
public class ClientHandler implements Runnable{
    private Socket socket;
    public ClientHandler(Socket socket){
        this.socket = socket;
    }

    public void run() {
        //测试:读取客户端发送过来的内容
        try {
            InputStream in = socket.getInputStream();
            int d;
            while ((d = in.read())!=-1){
                System.out.print((char)d);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
